import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/** 前端给后端传参 方法二：通过 form表单 构造 post 请求，访问 servlet 代码，然后传递参数
 * 在前端中 构造 form表单
 */

@WebServlet("/postParameter")
public class PostParameterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String aa = req.getParameter("aa");
        String bb = req.getParameter("bb");
        resp.setContentType("text/html");
        resp.getWriter().write("aa = " + aa + " bb = " + bb);

    }

}
